package com.gupao.observerdemo.observer.subject;

import com.gupao.observerdemo.observer.core.Event;

import java.lang.reflect.Method;

public class ObserverTest {
    public static void main(String[] args) {

        //观察者
        Observer observer = new Observer();
        //被观察者
        Subject subject = new Subject();
        try {
            Method callback = Observer.class.getMethod("advice", Event.class);
            //添加监听事件，
            subject.addListener(SubjectEventType.ON_ADD,observer,callback);
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }
        subject.add();
    }
}
